package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Peisongzhan;
import com.ruoyi.system.service.IPeisongzhanService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 配送站Controller
 * 
 * @author ruoyi
 * @date 2024-08-13
 */
@RestController
@RequestMapping("/system/peisongzhan")
public class PeisongzhanController extends BaseController
{
    @Autowired
    private IPeisongzhanService peisongzhanService;

    /**
     * 查询配送站列表
     */
    @PreAuthorize("@ss.hasPermi('system:peisongzhan:list')")
    @GetMapping("/list")
    public TableDataInfo list(Peisongzhan peisongzhan)
    {
        startPage();
        List<Peisongzhan> list = peisongzhanService.selectPeisongzhanList(peisongzhan);
        return getDataTable(list);
    }

    /**
     * 导出配送站列表
     */
    @PreAuthorize("@ss.hasPermi('system:peisongzhan:export')")
    @Log(title = "配送站", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Peisongzhan peisongzhan)
    {
        List<Peisongzhan> list = peisongzhanService.selectPeisongzhanList(peisongzhan);
        ExcelUtil<Peisongzhan> util = new ExcelUtil<Peisongzhan>(Peisongzhan.class);
        util.exportExcel(response, list, "配送站数据");
    }

    /**
     * 获取配送站详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:peisongzhan:query')")
    @GetMapping(value = "/{pszId}")
    public AjaxResult getInfo(@PathVariable("pszId") Long pszId)
    {
        return success(peisongzhanService.selectPeisongzhanByPszId(pszId));
    }

    /**
     * 新增配送站
     */
    @PreAuthorize("@ss.hasPermi('system:peisongzhan:add')")
    @Log(title = "配送站", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Peisongzhan peisongzhan)
    {
        return toAjax(peisongzhanService.insertPeisongzhan(peisongzhan));
    }

    /**
     * 修改配送站
     */
    @PreAuthorize("@ss.hasPermi('system:peisongzhan:edit')")
    @Log(title = "配送站", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Peisongzhan peisongzhan)
    {
        return toAjax(peisongzhanService.updatePeisongzhan(peisongzhan));
    }

    /**
     * 删除配送站
     */
    @PreAuthorize("@ss.hasPermi('system:peisongzhan:remove')")
    @Log(title = "配送站", businessType = BusinessType.DELETE)
	@DeleteMapping("/{pszIds}")
    public AjaxResult remove(@PathVariable Long[] pszIds)
    {
        return toAjax(peisongzhanService.deletePeisongzhanByPszIds(pszIds));
    }
}
